package ex4.gui;


import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

import ex4.logic.Configuration;
import ex4.logic.IceAgeSnake;
import ex4.logic.Ornamental;
import ex4.logic.Preadtor;



public class SnakeGameFirstScreen extends JFrame implements ActionListener{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JButton _iceAgeSnake;
	private JButton _ornamental;
	private JButton _preadtor;
	private JButton _exitButton;



	public SnakeGameFirstScreen(){
		super("Snake Game");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.getContentPane().setLayout(new GridLayout(4,1));

		this._iceAgeSnake = new JButton("IceAgeSnake");
		this._ornamental = new JButton("Ornamental");
		this._preadtor = new JButton("Preadtor");
		this._exitButton = new JButton("Exit");

		this._iceAgeSnake.addActionListener(this);
		this._ornamental.addActionListener(this);
		this._preadtor.addActionListener(this);
		this._exitButton.addActionListener(this);

		this.getContentPane().add(this._iceAgeSnake);
		this.getContentPane().add(this._ornamental);
		this.getContentPane().add(this._preadtor);
		this.getContentPane().add(this._exitButton);

		this.setSize(800,600);
		this.setResizable(true);
		this.setVisible(true);

	}


	/**
	 * This method invoked when some button pressed on the main menu.
	 * 
	 */
	@Override
	public void actionPerformed(ActionEvent e) {

		if (e.getSource().equals(this._exitButton))
			System.exit(0);

		if (e.getSource().equals(this._iceAgeSnake)){

			Game tGame = new Game(new IceAgeSnake(Configuration.REGULARSPEED));
			tGame.setSize(800,600);
			tGame.setVisible(true);
			this.dispose();

		}

		if (e.getSource().equals(this._preadtor)){

			Game tGame = new Game(new Preadtor(Configuration.REGULARSPEED));
			tGame.setSize(800,600);
			tGame.setVisible(true);
			this.dispose();

		}

		if (e.getSource().equals(this._ornamental)){

			Game tGame = new Game(new Ornamental(Configuration.REGULARSPEED));
			tGame.setSize(800,600);
			tGame.setVisible(true);
			this.dispose();
		}

	}



}
